<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=latin1">
        <link rel="stylesheet" type="text/css" href="../padrao.css" />
        <link rel="stylesheet" href="../jQuery/lista.css" type="text/css" media="all" />
        <script type="text/javascript" src="../simpleautocomplete/js/jquery.js"></script>
        <script type="text/javascript" src="../simpleautocomplete/js/simpleAutoComplete.js"></script>
        <link rel="stylesheet" type="text/css" href="../simpleautocomplete/css/simpleAutoComplete.css" />
        <title></title>
    </head>
    <body>
        <?php
        session_start();
        $default_area = "Escritorio";
        $_SESSION[default_area] = $default_area;
        include '../infobox.php';
        include '../verifica_usuario.php';
        include '../functions.php';
        include '../functions_office.php';
        include '../menu.php';
        ?>
        <div class="conteudo">
            <p class="titulopesquisa" align='center'> CAIXA </p>


            <?php
            //DIA
            echo "<p class='titulopesquisa' align='center'> HOJE </p>";
            include("mysqlconfig.inc");
//            $query = "  select funcionarios_login, data, SUM(valor) as total_dia, SUM(viagens) as creditos, tipo_viagem, count(tipo_viagem) as vendas, tipo_pagamento from VENDAS
//                        GROUP BY funcionarios_login, tipo_viagem, data, tipo_pagamento
//                        HAVING data > CURDATE()-2
//                        ORDER BY funcionarios_login,data;";
            $query = "SELECT * FROM CAIXA WHERE data_inicio = CURDATE() ORDER BY data_inicio, hora_inicio DESC ";


            $res = mysql_query($query);
            $num_reg = mysql_num_rows($res);
            
            echo "<table> ";
            echo "<tr class='titulo'>";
            echo "<td> Funcionario </td>";
            echo "<td> Aterro </td>";
            echo "<td> Dat INI </td>";
            echo "<td> Hor INI </td>";
            echo "<td> Dat FIM </td>";
            echo "<td> Hor FIM </td>";
            echo "<td> Saldo </td>";
            echo "<td> Poly </td>";
            echo "<td> Truck </td>";
            echo "<td> Toco </td>";
            echo "<td> Carreta </td>";
            echo "<td> Transbordo </td>";
            echo "</tr>";

            for ($i = 0; $i < $num_reg; $i++) {
                $mostra = mysql_fetch_array($res);
                $placa = $mostra[placa];
                if ($i % 2 == 1) {
                    $tipolinha = "tipo1";
                } else {
                    $tipolinha = "tipo2";
                }
                echo "<tr class='$tipolinha'>";

                echo "<td> $mostra[FUNCIONARIOS_login]";

                $query1 = "SELECT * FROM FUNCIONARIOS WHERE login = '$mostra[FUNCIONARIOS_login]'";
                $res1 = mysql_query($query1);
                $mostra1 = mysql_fetch_array($res1);
                if($mostra1[area] == "Escritorio"){
                    echo "<td> Escritorio </td>";
                } else {
                    echo "<td> $mostra1[ATERROS_nome] </td>";
                }
                echo "<td> $mostra[data_inicio] </td>";
                echo "<td> $mostra[hora_inicio] </td>";
                echo "<td> $mostra[data_fim] </td>";
                echo "<td> $mostra[hora_fim] </td>";
                echo "<td> $mostra[saldo] R$ </td>";
                echo "<td> $mostra[cred_poly] </td>";
                echo "<td> $mostra[cred_truck] </td>";
                echo "<td> $mostra[cred_toco] </td>";
                echo "<td> $mostra[cred_carreta] </td>";
                echo "<td> $mostra[cred_transbordo] </td>";
                
                echo "</tr>";

                //formata nome
                $nome = $mostra[funcionarios_login];
            }
            echo "</form>";
            echo "</table>";
            mysql_close($con);




            //HISTORICO
            echo "<br><hr><br>";
            echo "<p class='titulopesquisa' align='center'> HISTORICO </p>";



            include("mysqlconfig.inc");
//            $query = "  select funcionarios_login, data, SUM(valor) as total_dia, SUM(viagens) as creditos, tipo_viagem, count(tipo_viagem) as vendas, tipo_pagamento from VENDAS
//                        GROUP BY funcionarios_login, tipo_viagem, data, tipo_pagamento
//                        HAVING data > CURDATE()-2
//                        ORDER BY funcionarios_login,data;";

            $query2 = "SELECT * FROM CAIXA ORDER BY data_inicio, hora_inicio DESC";


            $res2 = mysql_query($query2);
            $num_reg2 = mysql_num_rows($res2);

            echo "<table> ";
            echo "<tr class='titulo'>";
            echo "<td> Funcionario </td>";
            echo "<td> Local </td>";
            echo "<td> Dat INI </td>";
            echo "<td> Hor INI </td>";
            echo "<td> Dat FIM </td>";
            echo "<td> Hor FIM </td>";
            echo "<td> Saldo </td>";
            echo "<td> Poly </td>";
            echo "<td> Truck </td>";
            echo "<td> Toco </td>";
            echo "<td> Carreta </td>";
            echo "<td> Transbordo </td>";
            echo "</tr>";

            for ($i = 0; $i < $num_reg2; $i++) {
                $mostra = mysql_fetch_array($res2);
                $placa = $mostra[placa];
                if ($i % 2 == 1) {
                    $tipolinha = "tipo1";
                } else {
                    $tipolinha = "tipo2";
                }
                echo "<tr class='$tipolinha'>";

                echo "<td> $mostra[FUNCIONARIOS_login]";
                $query1 = "SELECT * FROM FUNCIONARIOS WHERE login = '$mostra[FUNCIONARIOS_login]'";
                $res1 = mysql_query($query1);
                $mostra1 = mysql_fetch_array($res1);
                if($mostra1[area] == "Escritorio"){
                    echo "<td> Escritorio </td>";
                } else {
                    echo "<td> $mostra1[ATERROS_nome] </td>";
                }
                echo "<td> $mostra[data_inicio] </td>";
                echo "<td> $mostra[hora_inicio] </td>";
                echo "<td> $mostra[data_fim] </td>";
                echo "<td> $mostra[hora_fim] </td>";
                echo "<td> $mostra[saldo] R$ </td>";
                echo "<td> $mostra[cred_poly] </td>";
                echo "<td> $mostra[cred_truck] </td>";
                echo "<td> $mostra[cred_toco] </td>";
                echo "<td> $mostra[cred_carreta] </td>";
                echo "<td> $mostra[cred_transbordo] </td>";
                
                echo "</tr>";

                //formata nome
                $nome = $mostra[funcionarios_login];
            }
            echo "</form>";
            echo "</table>";
            mysql_close($con);
            ?>
        </div>
    </body>
</html>
